home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Fatted Calf
/
The Fatted Calf.iso
/
Applications
/
Conversion
/
Converters
/
shared.subproj
/
testNeXT2Mac.m
< prev
next >
Wrap
Text File
|
1993-04-04
|
3KB
|
92 lines
#import "NeXTToMacText.h"
#import "common.h"
#import <stdio.h>
void main()
{
Instance converter;
Integer index;
Character theChar, strictChar;
CString source = "Hi there how are you doing?";
ErrorCode errorone, errortwo;
FILE* theFile;
CString result, buffer;
Integer resultsize;
Integer ctr, colctr = 1;
converter = [[NeXTToMacText alloc] init];
//
// Convert an ascii char, an existing 8 bit char, and a characcter we know won't convert
//
theChar = [converter ConvertCharacter: 'A'];
errorone = [converter GetErrorCode];
printf("Character A: %c (bool result: %d)\n", theChar, errorone);
theChar = [converter ConvertCharacter: 0xB6];
errorone = [converter GetErrorCode];
printf("Character paragraph: %c (bool result: %d)\n", theChar, errorone);
theChar = [converter ConvertCharacter: 0xE6];
errorone = [converter GetErrorCode];
printf("Can't convert eth : %c (bool result: %d)\n", theChar, errorone);
for (index = 0; index < 256; index++)
{
theChar = [converter ConvertCharacter: index];
errorone = [converter GetErrorCode];
[converter ConvertSingleQuotes: YES];
strictChar = [converter ConvertCharacter: index];
errortwo = [converter GetErrorCode];
[converter ConvertSingleQuotes: NO];
printf("Converting NeXT 0x%X to Mac 0x%X (%c) (error: %d) [quote mode: 0x%X (%c) (error: %d)]\n",
index,
theChar, theChar, errorone,
strictChar, strictChar, errortwo);
}
// part two.
buffer = NewCString(512);
for (ctr = 0; ctr < 256; ctr++)
{
if (colctr != 16)
{
buffer[ctr*2] = ctr;
buffer[(ctr*2)+1] = ' ';
colctr++;
}
else
{
buffer[ctr*2] = ctr;
buffer[(ctr*2)+1] = '\r';
colctr = 1;
}
}
buffer[512] = EndOfCString;
printf("Source text is: \n%s\n", &buffer[1]); // skip initial null
result =(CString) [converter ConvertString: (Pointer) buffer WithLength: 512];
resultsize = [converter GetIntegerFrom: SECOND_RESULT];
printf("Size of result: %d\n", resultsize);
printf("Results text is: \n");
for (ctr = 0; ctr < resultsize; ctr ++)
printf("%c", result[ctr]);
printf("\n");
// test that it expands its internal buffer alright by giving it some text which we
// know will multiply in size when it comes out. .. convert lots of Thorns
for (ctr = 0; ctr < 16; ctr++)
buffer[ctr] = 0xFC;
buffer[16] = EndOfCString;
printf("Source text is: \n%s\n", (CString)buffer);
result =(CString) [converter ConvertString: (Pointer) buffer WithLength: 16];
resultsize = [converter GetIntegerFrom: SECOND_RESULT];
printf("Size of result: %d\n", resultsize);
printf("Results text is: \n");
for (ctr = 0; ctr < resultsize; ctr ++)
printf("%c", result[ctr]);
printf("\n");
FreeCString(result);
FreeCString(buffer);
close(theFile);
[converter free];
}